package com.deere.workprocedure.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.deere.dao.GenericDao;
import com.deere.model.ProductionOrderItem;
import com.deere.model.WorkingProcedure;
/**
 * 计算价格服务，
 * @author zhaohongxing
 *
 */
@Service
public class WorkingProcedureService {
	
	@Autowired
	private GenericDao<WorkingProcedure> workingProcedureDao;
	/**
	 * 根据<code>partCode</code>检索
	 * @param partCode
	 * @return
	 */
	public List<WorkingProcedure> serachWorkingProcedure(String wpCode) {
		String query = "from WorkingProcedure where wpCode = '"+wpCode+"'";

		List<WorkingProcedure> procedures = null;
		procedures = workingProcedureDao.query(query);
		return procedures;
	}
	/**
	 * 查询计划单的生产状况
	 * @param itemId
	 * @return
	 */
	public List<WorkingProcedure> searchWorkingProcedureById(Integer itemId){
		String query = "from WorkingProcedure where itemId = '"+itemId+"'";
		List<WorkingProcedure> procedures = null;
		procedures = workingProcedureDao.query(query);
		return procedures;
	}
	/**
	 * 计算工序所需的费用
	 * @return
	 */
	public double calcWorkingProcedurePrice(){
		return 0;
	}
	/**
	 * 保存零件的加工工序流程
	 * @param itemWorkflow
	 */
	public void insertWorkingProcedure(WorkingProcedure procedure){
		workingProcedureDao.save(procedure);
	}
	/**
	 * 删除工序
	 * @param procedure
	 */
	public void deleteWorkingProcedure(WorkingProcedure procedure){
		workingProcedureDao.delete(procedure);
	}
}
